<?php


class Banner extends CActiveRecord
{
	const ORIENTATION_PORTRAIT = 1;
	const ORIENTATION_LANDSCAPE = 2;
	public $Vhqel22dvclb;
	
	public static function model($Vgmajjibziuy=__CLASS__)
	{
		return parent::model($Vgmajjibziuy);
	}

	
	public function tableName()
	{
		return 'banner';
	}

	
	public function rules()
	{
		
		
		return array(
			array('url', 'required'),
			array('width, height, file_size, status, image_type, image_size_type, orientation, time', 'numerical', 'integerOnly'=>true),
			array('url', 'length', 'max'=>500),
			array('title', 'length', 'max'=>300),
			array('format', 'length', 'max'=>40),
			array('create_user_id', 'length', 'max'=>11),
			array('create_date', 'safe'),
			
			
			array('id, url, title, width, height, file_size, format, create_user_id, create_date, status, image_type, image_size_type, orientation, time', 'safe', 'on'=>'search'),
		);
	}

	
	public function relations()
	{
		
		
		return array(
		);
	}

	
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'url' => 'Url',
			'title' => 'Title',
			'width' => 'Width',
			'height' => 'Height',
			'file_size' => 'File Size',
			'format' => 'Format',
			'create_user_id' => 'Create User',
			'create_date' => 'Create Date',
			'status' => 'Status',
			'image_type' => 'Image Type',
			'image_size_type' => 'Image Size Type',
			'orientation' => 'Orientation',
			'time' => 'Time',
		);
	}

	
	public function search()
	{
		
		

		$V0v5vsnfxezw=new CDbCriteria;

		$V0v5vsnfxezw->compare('id',$this->id);
		$V0v5vsnfxezw->compare('url',$this->url,true);
		$V0v5vsnfxezw->compare('title',$this->title,true);
		$V0v5vsnfxezw->compare('width',$this->width);
		$V0v5vsnfxezw->compare('height',$this->height);
		$V0v5vsnfxezw->compare('file_size',$this->file_size);
		$V0v5vsnfxezw->compare('format',$this->format,true);
		$V0v5vsnfxezw->compare('create_user_id',$this->create_user_id,true);
		$V0v5vsnfxezw->compare('create_date',$this->create_date,true);
		$V0v5vsnfxezw->compare('status',$this->status);
		$V0v5vsnfxezw->compare('image_type',$this->image_type);
		$V0v5vsnfxezw->compare('image_size_type',$this->image_size_type);
		$V0v5vsnfxezw->compare('orientation',$this->orientation);
		$V0v5vsnfxezw->compare('time',$this->time);

		return new CActiveDataProvider($this, array(
			'criteria'=>$V0v5vsnfxezw,
		));
	}
	
	public function getListBanner() {
		$V0v5vsnfxezw=new CDbCriteria;

		$Vthjxlhsuevj = new CActiveDataProvider($this, array(
				'criteria'=>$V0v5vsnfxezw,
		));
	
		return $Vthjxlhsuevj;
	}
	
	public function getUrl() {
		if(strpos($this->url, 'http') === false) {
			$Vxun03s52uac = Yii::app()->baseUrl.'/banner/'.$this->url;
		}
		else {
			$Vxun03s52uac = $this->url;
		}
		return $Vxun03s52uac;
	}
	public function getStatus() {
		if($this->status){
			$Vxun03s52uac = CHtml::image(Yii::app()->baseUrl.'/images/spacer.gif','',array('class'=>'activeImage','id'=>'active_'.$this->id,'onclick'=>'changeActive('.$this->id.');'));
		}
		else {
			$Vxun03s52uac = CHtml::image(Yii::app()->baseUrl.'/images/spacer.gif','',array('class'=>'inactiveImage','id'=>'active_'.$this->id,'onclick'=>'changeActive('.$this->id.');'));
		}
		return $Vxun03s52uac;
	}
	
	public function getWidth() {
		$Vvzhqgqf4t4p = 0;
		$Vkfgbzexbozg = getimagesize('/var/www/html/vfilmbackend/backend/www/banner/'.$this->url);
		if(count($Vkfgbzexbozg) > 0) {
			$Vvzhqgqf4t4p = $Vkfgbzexbozg[0];
		}
		return $Vvzhqgqf4t4p;
	}

	public function getHeight() {
		$V0b1ihlordvk = 0;
		$Vkfgbzexbozg = getimagesize('/var/www/html/vfilmbackend/backend/www/banner/'.$this->url);
		if(count($Vkfgbzexbozg) > 0) {
			$V0b1ihlordvk = $Vkfgbzexbozg[1];
		}
		return $V0b1ihlordvk;
	}
	
	public function getImageSize() { 
		$Vkfgbzexbozg = getimagesize('/var/www/html/vfilmbackend/backend/www/banner/'.$this->url);
		return $Vkfgbzexbozg;		
	}
}